
#ifndef SERVERWIDGET_H
#define SERVERWIDGET_H

#include <BLineEdit>
#include <BButton>
#include <BTcpServer>
#include <BTcpSocket>
#include <BMainWindow>

#include "LoginDialog.h"
#include "DialogListWidget.h"

class ServerWidget : public BWidget
{
public:
	ServerWidget();
	~ServerWidget();

protected:
	bool sendMessage();

protected:
	void slotAddressEdited();
	void slotStartButtonClicked();
	void slotInputEditKeyDown(BObject* object, const BValue& value);
	void slotSendButtonClicked();
	void slotNewConnection(BObject* object, const BValue& value);
	void slotClientDisconnected(BObject* object, const BValue& value);
	void slotClientReadyRead(BObject* object, const BValue& value);
	void slotClientBytesSent(BObject* object, const BValue& value);

protected:
	virtual void updateEvent(const BEvent& event);
	virtual void styleEvent(const BEvent& event);

private:
	BLineEdit*				_addressEdit;
	BButton*			_startButton;
	DialogListWidget*	_dialogList;
	BLineEdit*				_inputEdit;
	BButton*			_sendButton;
	BTcpServer*			_server;
	BTcpSocketHolder	_client;
	BBuffer				_buffer;
	BIconHolder			_clientIcon;
};

#endif